package com.my.test.servlet.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class ContextLoaderListener implements ServletContextListener {

	//实现全局上下文初始化方法
	@Override
	public void contextInitialized(ServletContextEvent sce) {
		//获得全局变量
        ServletContext servletContext = sce.getServletContext();
        //设置全局变量属性
        servletContext.setAttribute("test","test1");
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {

	}

}
